Introduction

Duration: 5

What you'll learn?

Setup a Jenkins server to run the cicd pipelines

Why is this important?

Important part of MLOps

How it will work?

  1. Go to Play-with-docker site
  2. Pull the Jenkins docker
  3. Run the container
  4. Access Jenkins GUI and install plugins
  5. Create a pipeline
  6. Trigger the pipeline by pushing to git

Who is this for?

  1. People who are new to MLOps
  2. People willing to improve CICD skills

Login to PWD

Duration: 5

We will use Play with docker for this tutorial.

Sign-in

Go to this link and login. The landing page will look like this:

image.png

Create an instance

Click on ADD NEW INSTANCE. After clicking, it will look like this:

image.png

Run Jenkins docker

Duration: 2

docker run -p 8080:8080 -p 50000:50000 -d -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts

image.png

Get Jenkins password

Duration: 2

Run docker logs <container name> and get the password

image.png

Access Jenkins GUI

Duration: 2

Go to localhost:8080 and paste the copied password

image.png

Install the plugins

Duration: 2

Select Install suggested plugins option

image.png

Note down the Jenkin URL: http://ip172-18-0-30-c1d37qhbqvp000f2mu60-8080.direct.labs.play-with-docker.com/

Jenkins project types

Duration: 2

image.png

Add global credentials

Duration: 2

image.png

Create a new Jenkins job

Duration: 2

Create a new job, name it and select multi-branch as type. Repo might be https://gitlab.com/nanuchi/techworld-js-docker-demo-app/-/tree/jenkins-multi-input

Add git address and credentials

Duration: 2

image.png

Understand Pipeline format in Jenkinsfile

Duration: 2

image.png

image.png

Create Jenkinsfile

Duration: 2

pipeline {
    agent none
    stages {
        stage('Select micro services') {
            input {
                message "Select all micro services to deploy"
                ok "All selected!"
                parameters {
                    choice(name: 'MS1', choices: ['1.1.0', '1.2.0', '1.3.0'], description: 'input ms')
                    choice(name: 'MS2', choices: ['1.1.0', '1.2.0', '1.3.0'], description: 'input ms')
                    choice(name: 'MS3', choices: ['1.1.0', '1.2.0', '1.3.0'], description: 'input ms')
                    choice(name: 'MS4', choices: ['1.1.0', '1.2.0', '1.3.0'], description: 'input ms')
                }
            }
            steps {
                script {   
                    echo "Hello, ${MS1}. Hello, ${MS2}. Hello, ${MS3}. Hello, ${MS4}"
                    MS1_TO_DEPLOY = MS1
                    MS2_TO_DEPLOY = MS2
                    env.MS3_TO_DEPLOY = MS3
                    env.MS4_TO_DEPLOY = MS4      
                }
            }
        }
        stage('Select single service') {
            input {
                message "Select single micro services to deploy?"
                parameters {
                    choice(name: 'MS5', choices: ['1.1.0', '1.2.0', '1.3.0'], description: 'second param with single option')   
                }
            }
            steps {
                script {
                    echo "Hello, ${MS5}."  
                    env.MS5_TO_DEPLOY = MS5
                    echo "${MS1_TO_DEPLOY}"
                    echo "${MS4_TO_DEPLOY}"
                    echo "${MS5_TO_DEPLOY}"  
                }
            }
        }
    }
}

Trigger the pipeline job

Duration: 2

Pipeline can be triggered either by 1) Push notifications, or 2) Polling.

image.png

Check out the pipeline

Duration: 2

image.png